package com.lsb.blog.controller;

import com.lsb.blog.response.Result;
import com.lsb.blog.response.ResultCode;
import com.lsb.blog.service.LoginService;
import com.lsb.blog.vo.params.LoginParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：liusibo
 * @description：TODO
 * @date ：2021/8/4 11:17
 */
@RestController
@RequestMapping("/register")
public class RegisterController {

    @Autowired
    private LoginService loginService;

    @PostMapping
    public Result register(@RequestBody LoginParam loginParam){
        try {
            return loginService.register(loginParam);
        } catch (Exception e) {
            return Result.error(ResultCode.ACCOUNT_EXIST);
        }
    }
}
